package yesjava;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class MyObject {
    private int a = 0;
    private Lock lock = new ReentrantLock();

    public void add() {
        lock.lock();
        for (int i = 0; i < 100000; i++) {
            a++;
        }
        System.out.println(Thread.currentThread().getName() + " : " + a);
        lock.unlock();
    }


}
